{template 'common/header'}
<ul class="nav nav-tabs">
    <li {if $op=='list' } class="active" {/if}>
        <a href="{php echo $this->createWebUrl('user', array('op' => 'list'));}">用户列表</a>
    </li>
	{if $op=='zt' }
	<li class="active">
        <a href="#">直推用户列表</a>
    </li>
	{/if}
	{if $op=='jt' }
	<li class="active">
        <a href="#">间推用户列表</a>
    </li>
	{/if}
	{if $op=='post' }
	<li class="active">
        <a href="#">用户信息修改</a>
    </li>
	{/if}
</ul>
<?php
if($op == 'list' || $op == 'zt' || $op == 'jt' ){
?>
<div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{php echo $this->modulename}" />
				<input type="hidden" name="do" value="user" />
				

				<div class="form-group">
				    <label class="col-xs-12 col-sm-1 control-label" style="width: 5%;">注册日期</label>
					<div class="col-sm-2 col-xs-12" style="width: 15%;">{php echo tpl_form_field_daterange('daterange', $daterange)}</div>
					<label class="col-xs-12 col-sm-1 control-label" style="width: 8%;">昵称/会员号</label>
					<div class="col-sm-2 col-xs-12" style="width: 18%;">
						<input class="form-control" name="keyword2" id="" type="text" value="{$_GPC['keyword2']}" placeholder="根据用户昵称/会员号搜索">
					</div>
					<label class="col-xs-12 col-sm-1 control-label" style="width: 5%;">等级</label>
					<div class="col-sm-2 col-xs-12" style="width: 15%;">
                        <select name="keyword1" class="form-control">
						    <option value="9" >全部</option>
                            <option value="99" >{$settings['member_name']}</option>
							 <option value="1" >{$settings['tuan_name']}</option>
                            <option value="2" >{$settings['he_name']}</option>
                        </select>
                    </div>
					<div>
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
						<button type="button" class="btn btn-default">总记录数：{$total}</button>
					</div>
				</div>
			</form>
		</div>
</div>

<form action="" class="form-horizontal form" method="post" enctype="multipart/form-data">
    <div style="padding:15px;">
        <table class="table table-hover table-condensed">
            <thead class="navbar-inner">
                <tr>
                    <tr>

                    <th>id</th>

                    <th>上级</th>

                    <th>昵称</th>

					<th>openid</th>

					{if $settings['system_type'] == 1}<th>unionid</th>{/if}

                    <th>会员号</th>

					<th>直推人数</th>

					<th>间推人数</th>

					<th>余额</th>

					<th>积分</th>

                    <th>类型</th>

                    <th>注册时间</th>

                    <th>修改为</th>

                    <th style="text-align:right;">操作</th>

                </tr>
            </thead>
                <tbody id="level-list">

                {loop $list $item}
				<?php
				    $p_user = array();
					$user_ztall = array();
					$user_jtall = array();
				    if($settings['system_type'] == 1){
					    $p_user = pdo_get($this->modulename . "_user_u", array("uid" => $item['parent_id'],'system_id' => $settings['system_id']));
						$user_ztall = pdo_fetchall("SELECT count(*) as num FROM " . tablename($this->modulename . "_user_u") . " WHERE system_id = ".$settings['system_id']." and parent_id = ".$item['uid']);
						$user_jtall = pdo_fetchall("SELECT count(*) as num FROM " . tablename($this->modulename . "_user_u") . " WHERE system_id = ".$settings['system_id']." and parent_id != ".$item['uid']." and invite_uid like '%_".$item['uid']."%'");
					}else{
					    $p_user = pdo_get($this->modulename . "_user", array("uid" => $item['parent_id'],'uniacid' => $_W['uniacid']));
						$user_ztall = pdo_fetchall("SELECT count(*) as num FROM " . tablename($this->modulename . "_user") . " WHERE uniacid = ".$_W['uniacid']." and parent_id = ".$item['uid']);
						$user_jtall = pdo_fetchall("SELECT count(*) as num FROM " . tablename($this->modulename . "_user") . " WHERE uniacid = ".$_W['uniacid']." and parent_id != ".$item['uid']." and invite_uid like '%_".$item['uid']."%'");
					}
				?>

                <tr>

                    <td><div class="type-parent">{$item['user_id']}</div></td>

                    <td>

                        {if !empty($p_user['avatar'])}

                        <img style="width: 40px;" src="{$p_user['avatar']}">

                        {/if}

                        {$p_user['nickname']}

                    </td>

                    <td>

                        <img style="width: 40px;" src="{$item['avatar']}">

                        {$item['nickname']}

                    </td>

					<td>

                        {php echo substr($item['openid'], -10)}

                    </td>

					{if $settings['system_type'] == 1}
					<td>

                        {php echo substr($item['unionid'], -10)}

                    </td>
					{/if}

					<td>

                        {$item['uid']}

                    </td>

					<td>

                        <a class="btn btn-primary btn-sm" href="{php echo $this->createWebUrl('user',array('uid'=>$item['uid'],'op'=>'zt'))}" title="个人订单">{$user_ztall[0]['num']}</a>

                    </td>

					<td>

                        <a class="btn btn-primary btn-sm" href="{php echo $this->createWebUrl('user',array('uid'=>$item['uid'],'op'=>'jt'))}" title="个人订单">{$user_jtall[0]['num']}</a>

                    </td>

					<td>

                        {$item['money']}

                    </td>

					<td>

                        {$item['credit']}

                    </td>

                    <td>

                        <div class="type-parent">

                            {if $item['is_tuan']==0}

                                <span class="label label-primary">{$settings['member_name']}</span>

                            {elseif $item['is_tuan']==1}
							    <span class="label label-primary">{$settings['tuan_name']}</span>

                            {elseif $item['is_tuan']==2}
							    <span class="label label-primary">{$settings['he_name']}</span>

                            {/if}

                        </div>

                    </td>

                    <td><div class="type-parent">{php echo date('Y-m-d H:i:s',$item['create_time'])}</div></td>

                    <td>

                        {if $item['is_tuan']==0}
                            <a class="btn btn-primary btn-sm" href="{php echo $this->createWebUrl('user',array('op'=>'tuan','user_id'=>$item['user_id']))}" onclick="return confirm('确认设为{$settings['tuan_name']}？');return false;" title="设为{$settings['tuan_name']}">{$settings['tuan_name']}</a>
							<a class="btn btn-primary btn-sm" href="{php echo $this->createWebUrl('user',array('op'=>'he','user_id'=>$item['user_id']))}" onclick="return confirm('确认设为{$settings['he_name']}？');return false;" title="设为{$settings['he_name']}">{$settings['he_name']}</a>

                        {elseif $item['is_tuan']==1}
						    <a class="btn btn-primary btn-sm" href="{php echo $this->createWebUrl('user',array('op'=>'putong','user_id'=>$item['user_id']))}" onclick="return confirm('确认设为{$settings['member_name']}？');return false;" title="设为{$settings['member_name']}">{$settings['member_name']}</a>
							<a class="btn btn-primary btn-sm" href="{php echo $this->createWebUrl('user',array('op'=>'he','user_id'=>$item['user_id']))}" onclick="return confirm('确认设为{$settings['he_name']}？');return false;" title="设为{$settings['he_name']}">{$settings['he_name']}</a>

                        {elseif $item['is_tuan']==2}
                            <a class="btn btn-primary btn-sm" href="{php echo $this->createWebUrl('user',array('op'=>'putong','user_id'=>$item['user_id']))}" onclick="return confirm('确认设为{$settings['member_name']}？');return false;" title="设为{$settings['member_name']}">{$settings['member_name']}</a>
							<a class="btn btn-primary btn-sm" href="{php echo $this->createWebUrl('user',array('op'=>'tuan','user_id'=>$item['user_id']))}" onclick="return confirm('确认设为{$settings['tuan_name']}？');return false;" title="设为{$settings['tuan_name']}">{$settings['tuan_name']}</a>

                        {/if}

                    </td>

                    <td style="text-align:right;">
					    <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('order_user',array('uid'=>$item['uid'],'opp'=>'user'))}" title="个人订单">个人订单</a>
						<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('order_user',array('uid'=>$item['uid'],'opp'=>'team'))}" title="团队订单">团队订单</a>
						<a href="{php echo $this->createWebUrl('user', array('op' => 'post', 'user_id' => $item['user_id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>
                        <a class="btn btn-default btn-sm"   href="{php echo $this->createWebUrl('user',array('op'=>del,'user_id'=>$item['user_id']))}" onclick="return confirm('确认删除此用户吗？');return false;" title="删除">删除</a>

                    </td>

                </tr>
                {/loop}
            </tbody>
        </table>
        {$pager}
    </div>
</form>
<?php
}elseif($op == 'post'){
?>

<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<input type="hidden" name="id" value="{$adv['id']}" />
		<div class="panel panel-default">
			<div class="panel-heading">
				用户信息修改
			</div>
			<div class="panel-body">
			    <div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">用户UID</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" value="{$user['uid']}" disabled="disabled" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">openid</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" value="{$user['openid']}" disabled="disabled" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">unionid</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" value="{$user['unionid']}" disabled="disabled" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">昵称</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[nickname]" class="form-control" value="{$user['nickname']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">会员等级：</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="data[is_tuan]" value="0" {if $user['is_tuan'] == 0}checked="true"{/if} /> {$settings['member_name']}</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[is_tuan]" value="1" {if $user['is_tuan'] == 1}checked="true"{/if} /> {$settings['tuan_name']}</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[is_tuan]" value="2" {if $user['is_tuan'] == 2}checked="true"{/if} /> {$settings['he_name']}</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">上级UID</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[parent_id]" class="form-control" value="{$user['parent_id']}" />
						<span class="help-block" style="color:red;">*如果要修改上级，下面的邀请关系也要做相应修改</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">邀请关系</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[invite_uid]" class="form-control" value="{$user['invite_uid']}" />
						<span class="help-block" style="color:red;">*格式：0_间属上级UID_直属上级UID，例如：0_16801234_16801235_16801236</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">积分</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[credit]" class="form-control" value="{$user['credit']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">余额</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[money]" class="form-control" value="{$user['money']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">真实姓名</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[realname]" class="form-control" value="{$user['realname']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">手机号</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[mobile]" class="form-control" value="{$user['mobile']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">支付宝账号</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[alipayno]" class="form-control" value="{$user['alipayno']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否新用户：</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="data[new]" value="0" {if $user['new'] == 0}checked="true"{/if} /> 否</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[new]" value="1" {if $user['new'] == 1}checked="true"{/if} /> 是</label>
						<span class="help-block" style="color:red;">*用于计算拉新任务。</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否电影票管理员：</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="data[movie_ticketer]" value="0" {if $user['movie_ticketer'] == 0}checked="true"{/if} /> 否</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[movie_ticketer]" value="1" {if $user['movie_ticketer'] == 1}checked="true"{/if} /> 是</label>
						<span class="help-block" style="color:red;">*用于电影票报价通知。</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否黑名单：</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="data[is_black]" value="0" {if $user['is_black'] == 0}checked="true"{/if} /> 否</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[is_black]" value="1" {if $user['is_black'] == 1}checked="true"{/if} /> 是</label>
					</div>
				</div>
				
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>


<?php
}
?>
{template 'common/footer'}
